package com.pubinfo.passbook.common.model.http.request.AutoCreateWriteoff;

import com.fasterxml.jackson.dataformat.xml.annotation.JacksonXmlElementWrapper;
import com.fasterxml.jackson.dataformat.xml.annotation.JacksonXmlProperty;
import com.fasterxml.jackson.dataformat.xml.annotation.JacksonXmlRootElement;
import com.pubinfo.passbook.common.model.bo.witeoff.WiteoffBase;
import com.pubinfo.passbook.common.model.dto.open.WiteoffData;
import lombok.Data;
import org.apache.commons.lang3.StringUtils;

import java.io.Serializable;
import java.util.ArrayList;
import java.util.List;

@Data
@JacksonXmlRootElement(localName = "requestMessage")
public class AutoCreateWriteoffMessageList<T> implements Serializable {
  private static final long serialVersionUID = -4263564369107973676L;
  @JacksonXmlProperty(localName = "processCode")
  private String processCode = null;  // SFPTFQJT-CSKJ_02
  @JacksonXmlElementWrapper(localName = "writeoffItems")
  @JacksonXmlProperty(localName = "item")
  private List<T> item;
  
  public AutoCreateWriteoffMessageList() {
  }
  
  public AutoCreateWriteoffMessageList(WiteoffBase jobOrRetireDTO) {
    item = new ArrayList<>();
    item.add((T) jobOrRetireDTO);
    if (jobOrRetireDTO.getIsProcessShort()) {
      this.processCode = "SFPTFQJT-CSKJ_02"; // SFPTFQJT-CSKJ_02 直接到费用会计  SFPTFQJT-CSKJ_02_EPP 到分公司稽核会计
    }
  }
  
  public AutoCreateWriteoffMessageList(WiteoffData data) {
    item = new ArrayList<>();
    item.add((T) data);
    if (StringUtils.isNotBlank(data.getProcessCode())) {
      this.processCode = data.getProcessCode();
    }// 测试阶段走长流程
  }
//
//  public AutoCreateWriteoffMessageList(Object jobOrRetireDTO) {
//    item = new ArrayList<>();
//    item.add((T) jobOrRetireDTO);
//  }
}